package com.net.wanjian.networkhospitalmanager.net;

import com.net.wanjian.networkhospitalmanager.bean.DeviceOperationListResult;
import com.net.wanjian.networkhospitalmanager.bean.EnterLabResult;
import com.net.wanjian.networkhospitalmanager.bean.GetHospitalListReturn;
import com.net.wanjian.networkhospitalmanager.bean.LabReserveDetailResult;
import com.net.wanjian.networkhospitalmanager.bean.LabReserveListReturn;
import com.net.wanjian.networkhospitalmanager.bean.LoginReturn;
import com.net.wanjian.networkhospitalmanager.bean.ScanDeviceQRCodeResult;
import com.net.wanjian.networkhospitalmanager.bean.SearchDeviceDetailResult;
import com.net.wanjian.networkhospitalmanager.bean.SearchEvaluateResult;
import com.net.wanjian.networkhospitalmanager.bean.SearchMainRotateTeacherResult;
import com.net.wanjian.networkhospitalmanager.bean.SearchMessageListResult;
import com.net.wanjian.networkhospitalmanager.bean.SearchRotateStudentInfoListResult;
import com.net.wanjian.networkhospitalmanager.bean.SetMessageReadResult;
import com.net.wanjian.networkhospitalmanager.bean.SignResultBean;
import com.net.wanjian.networkhospitalmanager.bean.StudentApplyReserveReturn;
import com.net.wanjian.networkhospitalmanager.bean.StudentHistoryLabReserveResult;
import com.net.wanjian.networkhospitalmanager.bean.StudentLabReserveListResult;
import com.net.wanjian.networkhospitalmanager.bean.UserInfoReturn;
import com.net.wanjian.networkhospitalmanager.bean.Video.GetVideoClassifyBean;
import com.net.wanjian.networkhospitalmanager.bean.Video.GetVideoListBean;
import com.net.wanjian.networkhospitalmanager.bean.dopsminicex.GetScoreInformationBean;
import com.net.wanjian.networkhospitalmanager.bean.dopsminicex.NumberGetUserBean;
import com.net.wanjian.networkhospitalmanager.bean.dopsminicex.SearchEvaluationRecordByTeacher;
import com.net.wanjian.networkhospitalmanager.bean.dopsminicex.StudentInformationBean;
import com.net.wanjian.networkhospitalmanager.bean.evaluate.SaveEvaluationReturnResult;
import com.net.wanjian.networkhospitalmanager.bean.evaluate.SearchEventBasicInfoResult;
import com.net.wanjian.networkhospitalmanager.bean.evaluate.SearchEventEvaluateTableResult;
import com.net.wanjian.networkhospitalmanager.bean.evaluate.SearchHistoryEventTypeResult;
import com.net.wanjian.networkhospitalmanager.bean.evaluate.SearchTeacherEvaluationAllInfoListResult;
import com.net.wanjian.networkhospitalmanager.bean.teacherevent.DepartmentListResult;
import com.net.wanjian.networkhospitalmanager.bean.teacherevent.SearchEducatiationByConditionResult;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Description:
 * Created by lidongcai on 17/5/3.
 * Email:  lidongcaiocc@163.com
 */

public class HttpUtil {

    private static Retrofit mRetrofit;

    private static Api getRetrofit() {
        if (null == mRetrofit) {
            synchronized (HttpUtil.class) {
                if (null == mRetrofit) {
                    mRetrofit = new Retrofit.Builder()
                            .client(OkHttpUtil.getOkHttpUtil())
                            .addConverterFactory(GsonConverterFactory.create())
                            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                            .baseUrl(Api.BASE_URL)
                            .build();
                }
            }
        }
        return mRetrofit.create(Api.class);
    }

    /**
     * 将文件路径数组封装为{@link List<MultipartBody.Part>}
     *
     * @param //key       对应请求正文中name的值。目前服务器给出的接口中，所有图片文件使用<br>
     *                    多个name值，实际情况中有可能需要1个，改成一个key即可
     * @param filePaths   文件路径数组
     * @param //imageType 文件类型
     */
    public static List<MultipartBody.Part> files2Parts(String[] filePaths) {
        final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/jpeg");
        final String rootKey = "LabReserveMemberOperationImageContent_";
        List<MultipartBody.Part> parts = new ArrayList<>(filePaths.length);
        for (int i = 0; i < filePaths.length; i++) {
            String filePath = filePaths[i];
            File file = new File(filePath);
            // 根据类型及File对象创建RequestBody（okhttp的类）
            RequestBody requestBody = RequestBody.create(MEDIA_TYPE_PNG, file);
            // 将RequestBody封装成MultipartBody.Part类型（同样是okhttp的）
            MultipartBody.Part part = MultipartBody.Part.
                    createFormData(rootKey + i, file.getName(), requestBody);
            // 添加进集合
            parts.add(part);
        }
        return parts;
    }

    /**
     * 直接添加文本类型的Part到的MultipartBody的Part集合中
     *
     * @param parts    Part集合
     * @param key      参数名（name属性）
     * @param value    文本内容
     * @param position 插入的位置
     */
    public static void addTextPart(List<MultipartBody.Part> parts,
                                   String key, String value, int position) {
        RequestBody requestBody = RequestBody.create(MediaType.parse("text/plain"), value);
        MultipartBody.Part part = MultipartBody.Part.createFormData(key, null, requestBody);
        parts.add(position, part);
    }

    /**
     * 保存模型训练结果，图片和文字
     *
     * @param imagePaths
     * @param labReserveMemberOperationID
     * @param operationExperience
     * @param imageCount
     * @param d
     */
    public static void saveDeviceOperationImageUpload(String deviceId, String token, String hospitalId,
                                                      String[] imagePaths, String labReserveMemberOperationID,
                                                      String operationExperience, String imageCount,
                                                      DisposableObserver<StudentApplyReserveReturn> d) {

        //加入请求参数
        Map<String, RequestBody> params = new HashMap<>();
        params.put("LabReserveMemberOperationID", RequestBody.create(MediaType.parse("text/plain"), labReserveMemberOperationID));
        params.put("OperationExperience", RequestBody.create(MediaType.parse("text/plain"), operationExperience));
        params.put("ImageCount", RequestBody.create(MediaType.parse("text/plain"), imageCount));
        params.put("DeviceIdentity", RequestBody.create(MediaType.parse("text/plain"), deviceId));
        params.put("Token", RequestBody.create(MediaType.parse("text/plain"), token));
        params.put("CustomerInfoID", RequestBody.create(MediaType.parse("text/plain"), hospitalId));

        //加入上传文件参数
        List<MultipartBody.Part> files2Parts = files2Parts(imagePaths);

        getRetrofit().saveDeviceOperationImageUpload(params, files2Parts)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    };

    /**
     * 获取用户头像
     *
     * @param hospitalId
     * @param userInfoId
     * @param photoSizeType
     * @return
     */
    public static String getImageUrl(String hospitalId, String userInfoId, int photoSizeType) {
        return Api.BASE_URL + Api.USER_IMAGE + "?UserInfoID=" + userInfoId + "&PhotoSizeType=" + photoSizeType + "&CustomerInfoID=" + hospitalId;
    }

    /**
     * 获取设备图像
     *
     * @param deviceID
     * @return
     */
    public static String getDevicePhoto(String deviceID, String hospitalId) {
        return Api.BASE_URL + Api.DEVICE_PHOTO + "?DeviceID=" + deviceID + "&CustomerInfoID=" + hospitalId;
    }

    /**
     * 获取模型训练的图片
     *
     * @param labReserveMemberOperationImageID 实验室预约人员操作图片ID
     * @param hospitalId
     * @return
     */
    public static String getOperationDevicePhoto(String labReserveMemberOperationImageID, String hospitalId) {
        return Api.BASE_URL + Api.OPERATION_DEVICE_PHOTO + "?LabReserveMemberOperationImageID=" + labReserveMemberOperationImageID + "&CustomerInfoID=" + hospitalId;
    }


    /**
     * 获取医院列表
     *
     * @param d
     */
    public static void getHospitalList(DisposableObserver<GetHospitalListReturn> d) {
        getRetrofit().getHospitalListReturn()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 登录
     *
     * @param deviceId
     * @param id
     * @param name
     * @param wd
     * @param d
     */
    public static void userlogin(String deviceId, String id, String name, String wd, DisposableObserver<LoginReturn> d) {
        getRetrofit().userLogin(deviceId, id, name, wd)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    //扫描二维码
    public static void ScanSign(String QRCodeType, String EventType, String EventID, String StudentUserIdentityID, String DeviceIdentity, String Token, String CustomerInfoID, DisposableObserver<SignResultBean> z) {
        getRetrofit().ScanSign(QRCodeType, EventType, EventID, StudentUserIdentityID, DeviceIdentity, Token, CustomerInfoID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(z);
    }

    //签到
    public static void ScanSignInout(int EventType, String EventID, String StudentUserIdentityID, int SignType, int SignStyle, int QRCodeType, String DeviceIdentity, String Token, String CustomerInfoID, DisposableObserver<StudentApplyReserveReturn> z) {
        getRetrofit().ScanSignInout(EventType, EventID, StudentUserIdentityID, SignType, SignStyle, QRCodeType, DeviceIdentity, Token, CustomerInfoID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(z);
    }

    //阿里云视频-视频分类
    public static void GetVideoClassifyX(String Signature, String Format, String Version, String SignatureMethod, String SignatureVersion, String AccessKeyId,
                                         String Timestamp, String SignatureNonce, String Action, String PageNo, String PageSize, String CateId, DisposableObserver<GetVideoClassifyBean> z) {
        getRetrofit().GetVideoClassifyX(Signature, Format, Version, SignatureMethod, SignatureVersion, AccessKeyId, Timestamp, SignatureNonce, Action, PageNo, PageSize, CateId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(z);

    }

    //阿里云视频列表
    public static void GetVideoListX(String Signature, String Format, String Version, String SignatureMethod, String SignatureVersion, String AccessKeyId,
                                     String Timestamp, String SignatureNonce, String Action, String PageNo, String PageSize, String CateId, DisposableObserver<GetVideoListBean> z) {
        getRetrofit().GetVideoListX(Signature, Format, Version, SignatureMethod, SignatureVersion, AccessKeyId, Timestamp, SignatureNonce, Action, PageNo, PageSize, CateId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(z);
    }
    //Dop_s扫描用户身份二维码
    public static void ScanUserQRcode(String CustomerInfoID, String DeviceIdentity, String Token, String EncryptUserIdentityID, DisposableObserver<StudentInformationBean> z) {
        getRetrofit().ScanUserQRcode(CustomerInfoID, DeviceIdentity, Token, EncryptUserIdentityID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(z);
    }
    //通过用户编号获取用户信息
    public static void NumberGetUser(String CustomerInfoID, String DeviceIdentity, String Token, String EncryptUserIdentityID, DisposableObserver<NumberGetUserBean> z) {
        getRetrofit().NumberGetUser(CustomerInfoID, DeviceIdentity, Token, EncryptUserIdentityID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(z);
    }
    //获取项目打分评分表信息
    public static void GetScoreInformationX(String CustomerInfoID, String DeviceIdentity, String Token, String MarkSheetApplicationType, DisposableObserver<GetScoreInformationBean> z) {
        getRetrofit().GetScoreInformationX(CustomerInfoID, DeviceIdentity, Token, MarkSheetApplicationType)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(z);
    }


    /**
     * 获取用户信息
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userInfoId
     * @param d
     */
    public static void getUserInfo(String deviceId, String token, String hospitalId, String userInfoId, DisposableObserver<UserInfoReturn> d) {
        getRetrofit().getUserInfo(deviceId, token, hospitalId, userInfoId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }


    /**
     * 获取实验室预约列表
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param userIdentityTag
     * @param pageIndex
     * @param pageSize
     * @param d
     */
    public static void getLabreserveList(String deviceId, String token, String hospitalId, String userIndentityId,
                                         String userIdentityTag, int pageIndex, int pageSize, DisposableObserver<LabReserveListReturn> d) {
        getRetrofit().getLabreserveList(deviceId, token, hospitalId, userIndentityId, userIdentityTag, pageIndex, pageSize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 学生申请预约
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param labReserveID
     * @param d
     */
    public static void studentApplyReserve(String deviceId, String token, String hospitalId, String userIndentityId,
                                           String labReserveID, DisposableObserver<StudentApplyReserveReturn> d) {
        getRetrofit().studentApplyReserve(deviceId, token, hospitalId, userIndentityId, labReserveID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 获取学生实验室列表
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param pageIndex
     * @param pageSizem
     * @param d
     */
    public static void studentLabReserveList(String deviceId, String token, String hospitalId, String userIndentityId,
                                             int pageIndex, int pageSizem, DisposableObserver<StudentLabReserveListResult> d) {
        getRetrofit().studentLabReserveList(deviceId, token, hospitalId, userIndentityId, pageIndex, pageSizem)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 获取老师实验室列表
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param pageIndex
     * @param pageSizem
     * @param d
     */
    public static void teacherLabReserveList(String deviceId, String token, String hospitalId, String userIndentityId,
                                             int pageIndex, int pageSizem, DisposableObserver<StudentLabReserveListResult> d) {
        getRetrofit().teacherLabReserveList(deviceId, token, hospitalId, userIndentityId, pageIndex, pageSizem)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 学生取消预约
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param labReserveID
     * @param d
     */
    public static void studentCancelReserve(String deviceId, String token, String hospitalId, String userIndentityId,
                                            String labReserveID, DisposableObserver<StudentApplyReserveReturn> d) {
        getRetrofit().studentCancelReserve(deviceId, token, hospitalId, userIndentityId, labReserveID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 查看实验室预约详情
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param labReserveID
     * @param d
     */
    public static void labReserveDetail(String deviceId, String token, String hospitalId, String labReserveID,
                                        DisposableObserver<LabReserveDetailResult> d) {
        getRetrofit().labReserveDetail(deviceId, token, hospitalId, labReserveID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 进入实验室身份验证
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param labReserveID
     * @param d
     */
    public static void enterLab(String deviceId, String token, String hospitalId, String userIndentityId,
                                String labReserveID, DisposableObserver<EnterLabResult> d) {
        getRetrofit().enterLab(deviceId, token, hospitalId, userIndentityId, labReserveID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 获取实验模型训练列表
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param labReserveMemberID
     * @param d
     */
    public static void getDeviceOperationList(String deviceId, String token, String hospitalId, String labReserveMemberID, DisposableObserver<DeviceOperationListResult> d) {
        getRetrofit().getDeviceOperationList(deviceId, token, hospitalId, labReserveMemberID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }


    /**
     * 确认实验室预约回执信息（指导教师）
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param labReserveID
     * @param labReserveGuideTeacherIsReply
     * @param d
     */
    public static void teacherReplyLabReserve(String deviceId, String token, String hospitalId, String userIndentityId,
                                              String labReserveID, String labReserveGuideTeacherIsReply, DisposableObserver<StudentApplyReserveReturn> d) {
        getRetrofit().teacherReplyLabReserve(deviceId, token, hospitalId, userIndentityId, labReserveID, labReserveGuideTeacherIsReply)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 扫描二维码替换指导教师
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param labReserveID
     * @param encryptUserIdentityID
     * @param d
     */
    public static void replaceGuidTeacher(String deviceId, String token, String hospitalId, String userIndentityId,
                                          String labReserveID, String encryptUserIdentityID, DisposableObserver<StudentApplyReserveReturn> d) {
        getRetrofit().replaceGuidTeacher(deviceId, token, hospitalId, userIndentityId, labReserveID, encryptUserIdentityID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 依据二维码查询模型的基本信息
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param labReserveID
     * @param encryptDeviceID
     * @param d
     */
    public static void scanQRcodeGetDeviceInfo(String deviceId, String token, String hospitalId, String userIndentityId,
                                               String labReserveID, String encryptDeviceID, DisposableObserver<ScanDeviceQRCodeResult> d) {
        getRetrofit().scanQRcodeGetDeviceInfo(deviceId, token, hospitalId, userIndentityId, labReserveID, encryptDeviceID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 查询模型训练详情
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param labReserveMemberOperationID
     * @param d
     */
    public static void searchDeviceDetail(String deviceId, String token, String hospitalId, String labReserveMemberOperationID, DisposableObserver<SearchDeviceDetailResult> d) {
        getRetrofit().searchDeviceDetail(deviceId, token, hospitalId, labReserveMemberOperationID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 删除模型训练记录
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param labReserveMemberOperationID
     * @param d
     */
    public static void removeDeviceOperation(String deviceId, String token, String hospitalId, String labReserveMemberOperationID, DisposableObserver<StudentApplyReserveReturn> d) {
        getRetrofit().removeDeviceOperation(deviceId, token, hospitalId, labReserveMemberOperationID)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 查询学生历史预约列表
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param pageIndex
     * @param pageSizem
     * @param d
     */
    public static void studentHistoryLabReserveList(String deviceId, String token, String hospitalId, String userIndentityId,
                                                    int pageIndex, int pageSizem, DisposableObserver<StudentHistoryLabReserveResult> d) {
        getRetrofit().studentHistoryLabReserveList(deviceId, token, hospitalId, userIndentityId, pageIndex, pageSizem)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 查询科室选择条件
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param d
     */
    public static void getDepartmentList(String deviceId, String token, String hospitalId, DisposableObserver<DepartmentListResult> d) {
        getRetrofit().getDepartmentList(deviceId, token, hospitalId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 查询教学事件列表（科室或专业方向）
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param departmentID queryType为3设置科室id的值，如果为2传null即可
     * @param queryType    2 - 全部科室 3 - 具体科室
     * @param pageIndex
     * @param pageSize
     * @param d
     */
    public static void SearchEducatiationActivityByCondition(String deviceId, String token, String hospitalId, String departmentID, int queryType, int pageIndex,
                                                             int pageSize, DisposableObserver<SearchEducatiationByConditionResult> d) {
        getRetrofit().SearchEducatiationActivityByCondition(deviceId, token, hospitalId, departmentID, queryType, pageIndex, pageSize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }


    /**
     * 关键字查询（教学事件名称和主讲人的名称）
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param Keyword    查询关键字
     * @param pageIndex
     * @param pageSize
     * @return
     */
    public static void searchEducatiationActivityByKeyword(String deviceId, String token, String hospitalId, String Keyword, int pageIndex,
                                                           int pageSize, DisposableObserver<SearchEducatiationByConditionResult> d) {
        getRetrofit().searchEducatiationActivityByKeyword(deviceId, token, hospitalId, Keyword, pageIndex, pageSize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 修改个人密码
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userInfoId
     * @param userInfoOldPassword
     * @param userInfoNewPassword
     * @param d
     */
    public static void saveModifyUserPassword(String deviceId, String token, String hospitalId, String userInfoId, String userInfoOldPassword, String userInfoNewPassword, DisposableObserver<StudentApplyReserveReturn> d) {
        getRetrofit().saveModifyUserPassword(deviceId, token, hospitalId, userInfoId, userInfoOldPassword, userInfoNewPassword)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }


    /**
     * 获取消息通知列表，条件查询
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param messageTag              消息通知标签，多个用,分隔
     * @param pageIndex
     * @param pageSize
     * @param messageContentEventType 事件类型 全部：-1，实验室预约：0，教学行为：1
     * @param d
     */
    public static void searchMessageList(String deviceId, String token, String hospitalId, String userIndentityId,
                                         String messageTag, int pageIndex, int pageSize, int messageContentEventType,
                                         DisposableObserver<SearchMessageListResult> d) {
        getRetrofit().searchMessageList(deviceId, token, hospitalId, userIndentityId,
                messageTag, pageIndex, pageSize, messageContentEventType)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }


    /**
     * 设置消息通知为已读
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param messageContentIDString 消息通知ID集合，ID之间用英文逗号隔开
     * @param d
     */
    public static void setMessageRead(String deviceId, String token, String hospitalId, String userIndentityId, String messageContentIDString,
                                      DisposableObserver<SetMessageReadResult> d) {
        getRetrofit().setMessageRead(deviceId, token, hospitalId, userIndentityId, messageContentIDString)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**********************轮转api*******************************/


    /**
     * 学生获取规培导师
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param userIdentityTag
     * @param d
     */
    public static void searchMainTeacherList(String deviceId, String token, String hospitalId, String userIndentityId, String userIdentityTag,
                                             DisposableObserver<SearchMainRotateTeacherResult> d) {
        getRetrofit().searchMainTeacherList(deviceId, token, hospitalId, userIndentityId, userIdentityTag)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 学生获取轮转信息
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param userIdentityTag
     * @param rotationYear
     * @param d
     */
    public static void searchRotationSchedulingList(String deviceId, String token, String hospitalId, String userIndentityId, String userIdentityTag, String rotationYear,
                                                    DisposableObserver<SearchRotateStudentInfoListResult> d) {
        getRetrofit().searchRotationSchedulingList(deviceId, token, hospitalId, userIndentityId, userIdentityTag, rotationYear)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**********************事件评价api*******************************/

    /**
     * 获取历史事件类型和标签
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param d
     */
    public static void searchHistoryEventType(String deviceId, String token, String hospitalId,
                                              DisposableObserver<SearchHistoryEventTypeResult> d) {
        getRetrofit().searchHistoryEventType(deviceId, token, hospitalId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 查询事件列表接口（教学事件、考核事件、培训事件、公共事件）
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param loginPersonRole
     * @param eventExtendType
     * @param pageIndex
     * @param pageSize
     * @param d
     */
    public static void searchHistoryEventList(String deviceId, String token, String hospitalId, String userIndentityId,
                                              String loginPersonRole, String eventExtendType,
                                              int pageIndex, int pageSize, DisposableObserver<SearchEvaluateResult> d) {
        getRetrofit().searchHistoryEventList(deviceId, token, hospitalId, userIndentityId, loginPersonRole, eventExtendType, pageIndex, pageSize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);

    }


    /**
     * 去评价 获取评价项等信息
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId 用户身份ID
     * @param loginPersonRole 登陆任务角色
     * @param eventID         事件ID
     * @param eventType       事件类型 0：教学事件；1：考核事件；3：实验室预约；4：公共事件；
     * @param d
     */
    public static void searchEvaluateTable(String deviceId, String token, String hospitalId, String userIndentityId,
                                           String loginPersonRole, String eventID, String eventType, DisposableObserver<SearchEventEvaluateTableResult> d) {
        getRetrofit().searchEvaluateTable(deviceId, token, hospitalId, userIndentityId, loginPersonRole, eventID, eventType)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }


    /**
     * 保存评价信息
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param loginPersonRole         登陆人角色
     * @param eventType               事件类型
     * @param eventID                 事件ID
     * @param userIndentityId         用户身份ID
     * @param evaluationItemValueList 评价项集合 json格式 SaveEvaluationItemBean
     * @param d
     */
    public static void saveEvaluationTableInfo(String deviceId, String token, String hospitalId, String loginPersonRole,
                                               String eventType, String eventID, String userIndentityId,
                                               String evaluationItemValueList, DisposableObserver<SaveEvaluationReturnResult> d) {
        getRetrofit().saveEvaluationTableInfo(deviceId, token, hospitalId, loginPersonRole, eventType, eventID, userIndentityId, evaluationItemValueList)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 分别查询对人、对事的评价基本信息和老师信息
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param eventID    事件ID
     * @param eventType  事件类型
     * @param d
     */
    public static void searchEventBasicInfo(String deviceId, String token, String hospitalId, String eventID,
                                            String eventType, DisposableObserver<SearchEventBasicInfoResult> d) {
        getRetrofit().searchEventBasicInfo(deviceId, token, hospitalId, eventID, eventType)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 分别查询对人、对事的评价详细信息（可分类查询全部、好评、中评、差评）
     *
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param eventType                 0：教学事件；1：考核事件；3：实验室预约；4：公共事件；
     * @param eventID                   事件ID
     * @param beEvaluatedUserIdentityID 老师的用户身份ID
     * @param evaluationType            0:教师评价 1:事件评价
     * @param resultType                目前为:好\中\差 ;0:全部 1:好评 2:中评 3 差评
     * @param pageIndex
     * @param pageSize
     * @param d
     */
    public static void searchEvaluationTableList(String deviceId, String token, String hospitalId, String eventType,
                                                 String eventID, String beEvaluatedUserIdentityID, int evaluationType,
                                                 int resultType, int pageIndex, int pageSize, DisposableObserver<SearchTeacherEvaluationAllInfoListResult> d) {
        getRetrofit().searchEvaluationTableList(deviceId, token, hospitalId, eventType, eventID, beEvaluatedUserIdentityID,
                evaluationType, resultType, pageIndex, pageSize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

    /**
     * 获取Dops/Mini-cex评价记录列表（教师）
     * @param deviceId
     * @param token
     * @param hospitalId
     * @param userIndentityId
     * @param pageIndex
     * @param pageSize
     * @param evaluationRecordType
     * @param d
     */
    public static void SearchEvaluationRecordListByTeacher(String deviceId, String token, String hospitalId, String userIndentityId,
                                                            int pageIndex, int pageSize, int evaluationRecordType,
                                                           DisposableObserver<SearchEvaluationRecordByTeacher> d){
        getRetrofit().SearchEvaluationRecordListByTeacher(deviceId, token, hospitalId, userIndentityId, pageIndex, pageSize,evaluationRecordType)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(d);
    }

}
